package com.mage.myshop.config;


import com.mage.myshop.directive.ChildrenCategoryDirective;
import com.mage.myshop.directive.RootCategoryDirective;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Configuration
public class FreemarkerConfiguration {

    @Autowired
    private freemarker.template.Configuration configuration;
    @Autowired
    private RootCategoryDirective rootCategoryDirective;
    @Autowired
    private ChildrenCategoryDirective childrenCategoryDirective;

    @PostConstruct
    public void setSharedVariable() {
        // 设置共享变量
        configuration.setSharedVariable("rootCategory", rootCategoryDirective);
        configuration.setSharedVariable("childrenCategory", childrenCategoryDirective);
    }

}
